<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ZPituitaryDrugType extends Model
{
    protected $table = 'z_pituitary_drug_type';

    protected $guarded = ['id'];

    const CREATED_AT = 'create_at';

    const UPDATED_AT = 'update_at';

    public static function getAll($mode = 0)
    {
        //添加用药后 其他用药还是放在最下面 增加排序
        return self::from('z_pituitary_drug_type as a')
            ->select("b.drug_name", "b.drug_no", "b.general_name", "a.pid", "a.type_category", "a.type_name",
                "b.general_name_zm",  "b.id", "b.type_id")
            ->leftJoin("z_pituitary_drug as b", 'a.id', '=', 'b.type_id')
            ->where("a.pid", ">", 0)
            ->where("a.pid", $mode)
            ->orderBy("a.pid", "asc")
            ->orderBy("a.order_no", "asc")
            ->get()
            ->toArray();
    }
}
